package com.youlai.system.controller;

import com.youlai.system.common.result.Result;
import com.youlai.system.model.dto.CaptchaResult;
import com.youlai.system.model.dto.LoginResult;
import com.youlai.system.service.AuthEmployService;
import com.youlai.system.service.AuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Tag(name = "12.雇员认证中心")
@RestController
@RequestMapping("/api/v1/authEmployee")
@RequiredArgsConstructor
@Slf4j
public class AuthEmployController {
    private final AuthEmployService authEmployService;
    @Operation(summary = "登录")
    @PostMapping("/login")
    public Result<LoginResult> login(
            @Parameter(description = "工号", example = "陈亚飞") @RequestParam("workNumber") String username,
            @Parameter(description = "手机号", example = "123456") @RequestParam("mobile") String password
    ) {
        LoginResult loginResult = authEmployService.login(username, password);
        return Result.success(loginResult);
    }

    @Operation(summary = "注销")
    @DeleteMapping("/logout")
    public Result logout() {
        authEmployService.logout();
        return Result.success();
    }

    @Operation(summary = "获取验证码")
    @GetMapping("/captcha")
    public Result<CaptchaResult> getCaptcha() {
        CaptchaResult captcha = authEmployService.getCaptcha();
        return Result.success(captcha);
    }
}
